var materialFormMixin = function (materialField) {
  return {
    data: function () {
      return {
        isUpdateMaterialName: true
      };
    },

    methods: {
      resetMaterialName: function (hasSearch) {
        var material = this[materialField];
        var materialName = material.materialName;
        var defaultWarehouse = material.defaultWarehouse;
        if (['1','2'].indexOf(defaultWarehouse) !== -1) {
          defaultWarehouse = i18n.getMsg(`spotMaterial.defaultWarehouse.${defaultWarehouse}`);
        }

        if (defaultWarehouse === '原材料仓' && material.materialType.indexOf('板材') !== -1) {
          material.materialName = '胶板料';
          this.isUpdateMaterialName = false;
        } else {
          this.isUpdateMaterialName = true;
        }

        if (hasSearch) {
          if (materialName !== material.materialName) {
            this.searchMaterial(true);
          }
        }
      }
    }
  };
};
